#pragma once
#include "framework/service_interface.h"
#include "framework/request.h"
#include "framework/response.h"
#include "nlohmann/json.hpp"
namespace cpp_backend
{
    namespace services
    {
        class PingService : public framework::ServiceBase
        {
        public:
            PingService();
            virtual ~PingService() = default;
            // 重写服务接口方法
            bool Initialize() override;
            bool Start() override;
            void Stop() override;
            bool HealthCheck() override;
            // 处理请求
            framework::Response HandleRequest(const framework::Request &request);
            // 获取服务描述
            std::string GetServicedescription() const override;

        private:
            // 处理 ping请求
            framework::Response HandlePing(const framework::Request &request);
            // 处理 echo 请求
            framework::Response HandleEcho(const framework::Request &request);
            // 处理 info 请求
            framework::Response HandleInfo(const framework::Request &request);
            // 统计信息
            mutable std::atomic<int64_t> request_count_{0};
            mutable std::atomic<int64_t> ping_count_{0};
            mutable std::atomic<int64_t> echo_count_{0};
            std::chrono::system_clock::time_point start_time_;
        };
    }
}